Practice with Strings¶

👩🏻‍🎨 You already said that...¶

Write a program that queries a user for a list of fruits.

If the user says a fruit that has already been given, say "You already said that."

The program should ignore casing (uppercase vs lowercase).

Once 10 fruits have been given, print "Way to go!" and end the program.

fruits.py¶

Fruit: pear
Fruit: apple
Fruit: pear
You already said that.
Fruit: kiwi
Fruit: banana
Fruit: pear
You already said that.
Fruit: apple
You already said that.
Fruit: orange
Fruit: lemon
Fruit: lime
Fruit: cherry
Fruit: orange
You already said that.
Fruit: guava
Fruit: plum
Way to go!

🧑🏽‍🎨 Organized¶

Write a program that "organizes" user input.

"Organized" text means that all the characters are reordered to this sequence:

  • lowercase letters
  • uppercase letters
  • digits
  • everything else
  • whitespace is removed

organize.py¶

Text: Hello, what is your name?
ellowhatisyournameH,?
Text: BYU is my favorite school!
ismyfavoriteschoolBYU!
Text: 3.14159 is a loose approx. for PI.
isalooseapproxforPI314159...
Text:

👨🏿‍🎨 Swap¶

Write a program that asks the user for a phrase, then two words or substrings to swap.

Then swap the two words and print the result.

word_swap.py¶

Phrase: It's raining cats and dogs.
Word 1: cats
Word 2: dogs
It's raining dogs and cats.
Phrase: Do you like where you live?
Word 1: ke
Word 2: ve
Do you live where you like?
Phrase: